<template>
  <div v-if="show" class="CodeCcanningVerification">
    <!-- 公司logo -->
    <div class="CodeCcanningVerification_logo">
      <img :src="$base.baseImg + data.merchant.logo" />
    </div>
    <!-- 公司内容 -->
    <div class="CodeCcanningVerification_box">
      <h3>{{ data.merchant.mName }}</h3>
      <van-row>
        <van-col span="24">
          <a :href="'tel:' + data.merchant.phone">{{ data.merchant.phone }}</a>
          <p>商家地址：{{ data.merchant.address }}</p>
        </van-col>
        <!-- <van-col span="2">
          <img src="@/assets/address.png" alt="定位" />
        </van-col> -->
      </van-row>
    </div>
    <!-- 商品内容 -->
    <div class="codeCcanningVerification_table">
      <h2>商品规格</h2>
      <ul>
        <li>
          <div>商品名称</div>
          <div>数量</div>
        </li>
        <li v-for="(item, index) in data.proList" :key="index">
          <div>{{ item.proName }}</div>
          <div>{{ item.num }}</div>
        </li>
      </ul>
    </div>
    <!-- 核销按钮 -->
    <div class="CodeCcanningVerification_button">
      <van-button
        block
        color="#D2A166"
        @click="codeCcanningVerification"
        type="primary"
        >确定核销</van-button
      >
    </div>
  </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from "vue-property-decorator";
import QRCode from "qrcodejs2";
import { Col, Row, Button, Dialog, Toast } from "vant";

Vue.use(Button);
Vue.use(Col);
Vue.use(Row);
@Component({})
export default class CodeCcanningVerification extends Vue {
  private show = false;
  private data = {
    merchant: {},
    proList: [],
  };
  private mounted(): void {
    this.$common.getAuthToken(this.getData);
  }
  private getData(): void {
    this.$post(`getQrDetail`, {
      qrCode: this.$route.params.id,
    }).then((res: any) => {
      if (res.code == 0) {
        this.show = true;
        this.data = res.data;
      }
    });
  }

  private codeCcanningVerification(): void {
    Dialog.confirm({
      title: "温馨提示",
      message: "确定核销此订单？",
    })
      .then(() => {
        this.$post(`verifyQr`, {
          qrCode: this.$route.params.id,
        }).then((res: any) => {
          if (res.code == 0) {
            Toast(`核销成功!`);
          }
        });
      })
      .catch(() => {});
  }
}
</script>

<style lang="scss">
.CodeCcanningVerification {
  width: 100%;
  .CodeCcanningVerification_logo {
    width: 100%;
    padding: 30px;
    height: 300px;
    box-sizing: border-box;
    border-radius: 20px;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
      border-radius: 20px;
      display: block;
    }
  }
  .CodeCcanningVerification_box {
    width: 100%;
    padding: 30px;
    box-sizing: border-box;
    background-color: #fff;
    h3 {
      font-size: 32px;
      font-weight: 400;
      color: #000000;
      line-height: 1.5;
    }
    p {
      font-size: 30px;
      font-weight: 300;
      color: #343434;
      line-height: 1.5;
    }
    a {
      font-size: 30px;
      font-weight: 300;
      color: blue;
      line-height: 1.5;
    }
    img {
      width: 40px;
      display: block;
      float: right;
    }
  }
  .codeCcanningVerification_table {
    width: 100%;
    padding: 30px;
    background-color: #fff;
    box-sizing: border-box;
    margin-top: 30px;
    h2 {
      font-size: 32px;
      font-weight: 400;
      color: #000000;
      padding-left: 15px;
      box-sizing: border-box;
      border-left: 5px solid #d2ad61;
    }
    ul {
      list-style: none;
      overflow: hidden;
      margin-top: 30px;
      box-sizing: border-box;
      border-top: 1px solid #000;
      border-left: 1px solid #000;
      li {
        width: 100%;
        box-sizing: border-box;
        border-bottom: 1px solid #000;
        overflow: hidden;
        div {
          width: 50%;
          float: left;
          border-right: 1px solid #000;
          box-sizing: border-box;
          font-size: 30px;
          font-weight: 300;
          color: #343434;
          text-align: center;
          line-height: 2;
        }
      }
    }
  }
  .CodeCcanningVerification_button {
    position: fixed;
    width: 100%;
    left: 0;
    bottom: 0;
  }
}
</style>